#!/bin/bash

echo
if [ -z "${ONE_LOCATION}" ]; then
	LIB_LOCATION="/usr/lib/one"
	ETC_LOCATION="/etc/one"
else
	LIB_LOCATION="${ONE_LOCATION}/lib"
	ETC_LOCATION="${ONE_LOCATION}/etc"  
fi

# check dirs
if [ ! -d "$LIB_LOCATION" ]; then
	echo "OpenNebula installation not found"
	exit 1
fi

IM_DIR="${LIB_LOCATION}/remotes/im/vbox.d"
VMM_DIR="${LIB_LOCATION}/remotes/vmm/vbox"


echo "OpenNebula installation found:"
echo "......................LIB LOCATION: $LIB_LOCATION"
echo ".......VMM REMOTE SCRIPTS LOCATION: $VMM_DIR"
echo "........IM REMOTE SCRIPTS LOCATION: $IM_DIR"

echo "Removing vbox driver files..."
rm -rf "$IM_DIR"
rm -rf "$VMM_DIR"
rm "${ETC_LOCATION}/vmm_ssh/vmm_ssh_vbox.conf"

echo -e "\ndone."
